<template>
  <div class="new_album">
      <div class="title">新专速递</div>
    <div class="content_wrap">
      <div class="content">
        <div
          v-for="(item, index) in albumsList"
          :key="index"
          style="position: relative"
          class="image"
        >
          <div @click="toDetail(item.id)" class="image_wrap">
            <el-image lazy :src="item.blurPicUrl">
            </el-image>

            <div class="play_img">
              <img
                src="@/assets/image/play.svg"
                alt=""
                style="
                  width: 50px;
                  height: 50px;
                  background: #aca8a1;
                  border-radius: 100%;
                  opacity: 0.8;
                "
              />
            </div>
          </div>

          <span class="name">{{ item.name }}</span>
          <span class="artist_name">{{ item.artist.name }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {getNewAlbums} from '@/util/music.js'
export default {
  name: "Newalbum",

  data() {
    return {
        albumsList:{}
    };
  },

  created() {
    this.getNewAlbums();
  },

  methods: {
    //获取最新专辑
    async getNewAlbums() {
      let { data } = await getNewAlbums();
      this.albumsList = data.albums
    //   console.log(data);
    },
    toDetail(id){
        this.$router.push('/abumetail/'+id)
      this.$store.dispatch("musicPlay/saveIsPlaying", "false");

    }
  },
};
</script>

<style lang="less" scoped>
.new_album {
    padding: 1rem 8rem;
    .title{
        font-size: 50px;
        font-weight: 600;
    }
  .content_wrap {
    position: relative;
    margin-top: 30px;
    .content {
      // display: flex;
      // flex-wrap: wrap;
      display: grid;
      justify-content: space-around;
      grid-template-columns: repeat(auto-fill, 18rem);
      .image {
        margin-bottom: 45px;
        .image_wrap {
          position: relative;
          .el-image {
            border-radius: 10px;
          }
          .play_img {
            position: absolute;
            top: 50%;
            left: 50%;
            margin-left: -25px;
            margin-top: -25px;
            display: none;
            transition: all 1s 1s;
          }
        }
      }
      .image:hover .play_img {
        display: block;
      }
      .name {
        display: block;
        font-size: 16px;
        font-weight: 600;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
      .artist_name{
          font-size: 12px;
          color: rgb(105, 87, 87);
      }
    }
  }
}
</style>